/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.meego.common.timer;

import java.sql.Timestamp;
import java.util.Date;
import java.util.TreeMap;

/**
 *
 * @author TueHM
 */
public class Test implements TimedEvent {

    private static Test instance;

    public static Test getInstance() {
        if (instance == null) {
            instance = new Test();
        }
        return instance;
    }

    public Test() {
        EventTimer.getInstance().addTimedEvent("aaaaa", this);
    }

    @Override
    public void doTimedEvent() {
        System.out.println("time event: " + (new Timestamp(System.currentTimeMillis())));
    }

    @Override
    public Date getNextEvent() {
        return new Date(System.currentTimeMillis() + 5000);
    }

    public static void main(String[] args) {
        TreeMap<String, String> currAccount = new TreeMap<String, String>();
        currAccount.put("key1", "value1");
        currAccount.put("key2", "value2");
        currAccount.put("key3", "value3");
        currAccount.put("key4", "value4");
        String a = currAccount.firstEntry().getValue();
        currAccount.remove(a);
        System.out.println(a);
        a = currAccount.firstEntry().getValue();
        currAccount.remove(a);
        System.out.println(a);
        a = currAccount.firstEntry().getValue();
        currAccount.remove(a);
        System.out.println(a);
        System.out.println(currAccount.size());
    }
}
